home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2003 March / DPPCPRO0303.ISO / Components / Connector for iCat Commerce Online / data1.cab / Program_Executable_Files / iCat.jar / iCat / iCatECommerceDemo.class (.txt) < prev   
Encoding:
Java Class File  |  1998-11-13  |  4.3 KB  |  117 lines

  1. package iCat;
  2.  
  3. import com.netobjects.nfc.api.ApplicationComp;
  4. import com.netobjects.nfc.api.DFile;
  5. import com.netobjects.nfc.api.DFusion;
  6. import com.netobjects.nfc.api.DMessageBox;
  7. import com.netobjects.nfc.api.DNode;
  8. import com.netobjects.nfc.api.DRect;
  9. import com.netobjects.nfc.api.DSite;
  10. import com.netobjects.nfc.api.DSiteView;
  11. import java.awt.FileDialog;
  12. import java.awt.Frame;
  13.  
  14. public class iCatECommerceDemo extends ApplicationComp {
  15.    // $FF: renamed from: OK int
  16.    private static final int field_0 = 1;
  17.    private static final int CANCEL = 0;
  18.    private int m_user_action;
  19.    private int m_numChildren;
  20.    private String codebase;
  21.    private boolean success = false;
  22.    private DNode m_tempNode;
  23.    private DNode m_homeNode;
  24.    private DRect m_rect;
  25.    private FileDialog m_dialog;
  26.    private Frame m_frame;
  27.    private DMessageBox m_messageBox = new DMessageBox();
  28.  
  29.    public void onEnable(DSiteView var1) {
  30.       try {
  31.          this.codebase = ((ApplicationComp)this).getNFXCodeBase();
  32.          this.m_tempNode = new DNode();
  33.          this.m_homeNode = this.m_tempNode.getHomeNode();
  34.          this.m_numChildren = this.m_homeNode.getNumberOfChildren();
  35.          if (this.m_numChildren != 0) {
  36.             this.m_messageBox.Warning("Error: You must start with a new, blank site.");
  37.             return;
  38.          }
  39.  
  40.          if (this.m_homeNode != null) {
  41.             this.success = var1.importNFTemplate(this.codebase + "iCatDemo\\iCat.nft", this.m_homeNode);
  42.             if (!this.success) {
  43.                this.m_user_action = this.m_messageBox.Alert("Can't locate the iCat.nft template.\r\n Select 'OK' to locate the template manually.");
  44.  
  45.                while(this.m_user_action == 1) {
  46.                   this.m_frame = new Frame();
  47.                   this.m_frame.setBounds(150, 150, 0, 0);
  48.                   this.m_dialog = new FileDialog(this.m_frame);
  49.                   this.m_dialog.setMode(0);
  50.                   this.m_dialog.show();
  51.                   String var2 = this.m_dialog.getDirectory();
  52.                   String var3 = this.m_dialog.getFile();
  53.                   if (var3 != null) {
  54.                      if (var3.compareTo("iCat.nft") != 0) {
  55.                         this.m_user_action = this.m_messageBox.Alert("Error: This is not the iCat.nft template. /r/n Please select the iCat.nft template.");
  56.                      } else {
  57.                         this.m_user_action = 0;
  58.                         String var4 = var2 + var3;
  59.                         this.success = var1.importNFTemplate(var4, this.m_homeNode);
  60.                         if (!this.success) {
  61.                            this.m_messageBox.Warning("Error importing template.");
  62.                         } else {
  63.                            this.insertGIF(this.m_homeNode);
  64.                            this.writeiCatFile();
  65.                         }
  66.                      }
  67.                   } else {
  68.                      this.m_user_action = 0;
  69.                   }
  70.                }
  71.  
  72.                return;
  73.             }
  74.  
  75.             this.insertGIF(this.m_homeNode);
  76.             this.writeiCatFile();
  77.             return;
  78.          }
  79.       } catch (Throwable var5) {
  80.          this.m_messageBox.Warning("Error: " + var5);
  81.       }
  82.  
  83.    }
  84.  
  85.    private void insertGIF(DNode var1) {
  86.       try {
  87.          this.m_rect = new DRect();
  88.          this.m_rect.setTop(50);
  89.          this.m_rect.setLeft(50);
  90.          this.m_rect.setBottom(452);
  91.          this.m_rect.setRight(418);
  92.          var1.insertPictureObject2Page(this.codebase + "iCatDemo\\iCatMade.gif", this.m_rect);
  93.          this.m_messageBox.Warning("The iCat-NetObjects Integration Technical Note contains important information that you\r\nshould read before working with the sample Commerce Cart. Click OK to continue.");
  94.          DFusion var2 = new DFusion();
  95.          var2.OpenDefaultBrowser(false, "http://www.icat.com/ico/netobjects4.pdf", "");
  96.          var1.setNodeName("iCat Demo");
  97.       } catch (Throwable var3) {
  98.          this.m_messageBox.Warning("Error: " + var3);
  99.       }
  100.    }
  101.  
  102.    private void writeiCatFile() {
  103.       String var1 = "http://www4.icat.com/store/democart";
  104.       DSite var2 = new DSite();
  105.       String var3 = var2.getName();
  106.       DFile var4 = new DFile();
  107.       if (var4.Open(this.codebase + "\\iCatInfo\\" + var3 + ".txt", 4097)) {
  108.          var4.Seek(0, 0);
  109.          var4.WriteString(var1, -1);
  110.          var4.Close();
  111.       } else {
  112.          DMessageBox var5 = new DMessageBox();
  113.          var5.Warning("The file (" + this.codebase + "iCatInfo\\" + var3 + ".txt) could not be created.\r\n" + "Without this file the iCat components will not publish correctly.\r\n");
  114.       }
  115.    }
  116. }
  117.